import pygame, os, sys
from anim import anim_c

def loadImage(gameObj, imgTitle, imgPath, imgFilename, double = False):
	gameObj.img[imgTitle] = pygame.image.load(os.path.join(imgPath, imgFilename)) #.convert_alpha()
	if double:
		gameObj.img[imgTitle] = pygame.transform.scale(gameObj.img[imgTitle], (gameObj.img[imgTitle].get_width()*2, gameObj.img[imgTitle].get_height()*2))
	
"""
This creep anim stuff needs to go into the creeps' .py file
"""
	
def loadGameData(gameObj):
    #loadImage just dumps the image given into gameObj.img["imgName"]
    #loadImage(gameObj, "allCreeps","data","allLemmings.gif", False)
    loadImage(gameObj, "allDudes","data","dude-Final.gif", False)
    #loadImage(gameObj, "allDudes","data","dude-Final_mask.gif", False)
    loadImage(gameObj, "allDudes_mask","data","dude-Final_mask.png", False)
    
    loadImage(gameObj, "doorAnimExit","data","exitDoor.gif", False)
    loadImage(gameObj, "doorAnimEntrance","data","dooranimEntrance.gif", False)
    loadImage(gameObj, "explosion","data","explosion.gif", False)
    loadImage(gameObj, "menuSurface","data","menu.gif", False)
    loadImage(gameObj, "mouseSurface","data","cursor.gif", False)
    loadImage(gameObj, "menuItemBox","data","menuItemBox.gif", False)
         """
    creep animations
    surface, toSurface, animName, frameList, offsetX=0, offsetY=0 (pixels/32 down to start grabbing), handleX=0, handleY=0, sizeX=gameObj.spriteSize[0], sizeY=gameObj.spriteSize[1], loopAnim=True, animDelay=1
    """
    """
    old lemming anims
    gameObj.anim["fall_right"] = anim_c(gameObj.img["allCreeps"], gameObj, "fall_right", range(4), 0, 0, 15, 31)
    gameObj.anim["fall_left"] = anim_c(gameObj.img["allCreeps"], gameObj, "fall_left", range(3,-1,-1), 0, 1, 15, 31)
    gameObj.anim["walk_right"] = anim_c(gameObj.img["allCreeps"], gameObj, "walk_right", range(8), 0, 2, 15, 31)
    gameObj.anim["walk_left"] = anim_c(gameObj.img["allCreeps"], gameObj, "walk_left", range(7, -1, -1), 0, 3, 15, 31)
    gameObj.anim["miner_right"] = anim_c(gameObj.img["allCreeps"], gameObj, "miner_right", range(24), 0, 4, 15, 31)
    gameObj.anim["miner_left"] = anim_c(gameObj.img["allCreeps"], gameObj, "miner_left", range(23, -1, -1), 0, 5, 15, 31)
    gameObj.anim["builder_right"] = anim_c(gameObj.img["allCreeps"], gameObj, "builder_right", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], 0, 6, 15, 31)
    gameObj.anim["builder_left"] = anim_c(gameObj.img["allCreeps"], gameObj, "builder_left", [15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0], 0, 7, 15, 31)
    gameObj.anim["basher_right"] = anim_c(gameObj.img["allCreeps"], gameObj, "basher_right", range(32), 0, 8, 15, 31)
    gameObj.anim["basher_left"] = anim_c(gameObj.img["allCreeps"], gameObj, "basher_left", range(31,-1,-1), 0, 8, 15, 31)
    gameObj.anim["dig_down"] = anim_c(gameObj.img["allCreeps"], gameObj, "dig_down", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], 0, 10, 17, 26)
    gameObj.anim["float_start"] = anim_c(gameObj.img["allCreeps"], gameObj, "float_start", [0,1,2,3,4,5], 0, 11, 15, 31)
    gameObj.anim["floater"] = anim_c(gameObj.img["allCreeps"], gameObj, "floater", [0,1,2,3,4,5,6,7], 0, 12, 15, 31)
    gameObj.anim["blocker"] = anim_c(gameObj.img["allCreeps"], gameObj, "blocker", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], 0, 13, 15, 31)
    gameObj.anim["confused_right"] = anim_c(gameObj.img["allCreeps"], gameObj, "confused_right", [0,1,2,3,4,5,6,7], 0, 14, 15, 31)
    gameObj.anim["confused_left"] = anim_c(gameObj.img["allCreeps"], gameObj, "confused_left", [7,6,5,4,3,2,1,0], 0, 15, 15, 31)
    gameObj.anim["bomber"] = anim_c(gameObj.img["allCreeps"], gameObj, "bomber", [0,1,2,3,4,5,6,7], 0, 16, 15, 31)
    gameObj.anim["chunk1"] = anim_c(gameObj.img["allCreeps"], gameObj, "chunk1", [0,1,2,3,4,5,6,7,8,9,10,11,12], 0, 18, 15, 31)
    gameObj.anim["exitAnim"] = anim_c(gameObj.img["allCreeps"], gameObj, "exitAnim", [0,1,2,3,4,5,6,7], 0, 19, 15, 31)
    gameObj.anim["splut"] = anim_c(gameObj.img["allCreeps"], gameObj, "splut", range(16), 0, 20, 15, 31)
    """
	#anim["Anim_enum"]=anim_c(surface, gameObj, "anim name", [frame1, frame2, frame3...],  xoffset, yoffset/32, xhandle, yhandle)
    gameObj.anim["walk_right"] = anim_c(gameObj.img["allDudes"], gameObj, "walk_right", range(8), 0, 0, 15, 31)
    gameObj.anim["walk_left"] = anim_c(gameObj.img["allDudes"], gameObj, "walk_left", range(7, -1, -1), 0, 1, 15, 31)
    gameObj.anim["blocker"] = anim_c(gameObj.img["allDudes"], gameObj, "blocker", range(14), 0, 5, 15, 31)
    gameObj.anim["fall_right"] = anim_c(gameObj.img["allDudes"], gameObj, "fall_right", range(8), 0, 8, 15, 31)
    gameObj.anim["fall_left"] = anim_c(gameObj.img["allDudes"], gameObj, "fall_left", range(8), 0, 8, 15, 31)
    gameObj.anim["bomber"] = anim_c(gameObj.img["allDudes"], gameObj, "bomber", range(5), 0, 10, 15, 31)
    gameObj.anim["builder_right"] = anim_c(gameObj.img["allDudes"], gameObj, "builder_right", range(9), 0, 2, 15, 31)
    gameObj.anim["builder_left"] = anim_c(gameObj.img["allDudes"], gameObj, "builder_left", range(10, -1, -1), 0, 3, 15, 31)
    gameObj.anim["splut"] = anim_c(gameObj.img["allDudes"], gameObj, "splut", range(20), 0, 11, 15, 31)
    gameObj.anim["confused_right"] = anim_c(gameObj.img["allDudes"], gameObj, "confused_right", [0,1,2,3,4,5,5,5,4,3], 0, 12, 15, 31)
    gameObj.anim["confused_left"] = anim_c(gameObj.img["allDudes"], gameObj, "confused_left", [0,1,2,3,4,5,5,5,4,3], 0, 12, 15, 31)
    
    gameObj.anim["basher_right"] = anim_c(gameObj.img["allDudes"], gameObj, "basher_right", range(23), 0, 13, 15, 31)
    gameObj.anim["basher_right_mask"] = anim_c(gameObj.img["allDudes_mask"], gameObj, "basher_right_mask", range(23), 0, 0, 15, 31)
    gameObj.anim["basher_right"].setMask(gameObj.anim["basher_right_mask"])
    
    gameObj.anim["basher_left"] = anim_c(gameObj.img["allDudes"], gameObj, "basher_left", range(22,-1,-1), 0, 14, 15, 31)  
    gameObj.anim["basher_left_mask"] = anim_c(gameObj.img["allDudes_mask"], gameObj, "basher_left_mask", range(22,-1,-1), 0, 1, 15, 31)
    gameObj.anim["basher_left"].setMask(gameObj.anim["basher_left_mask"])

    #undrawn animations, currently set to confused but need to be drawn
    gameObj.anim["float_start"] = anim_c(gameObj.img["allDudes"], gameObj, "confused_right", [0,1,2,3,4,5,5,5,4,3], 0, 12, 15, 31)
    gameObj.anim["floater"] = anim_c(gameObj.img["allDudes"], gameObj, "confused_right", [0,1,2,3,4,5,5,5,4,3], 0, 12, 15, 31)
    gameObj.anim["exitAnim"] = anim_c(gameObj.img["allDudes"], gameObj, "confused_right", [0,1,2,3,4,5,5,5,4,3], 0, 12, 15, 31)

    gameObj.anim["entrance"] = anim_c(gameObj.img["doorAnimEntrance"], gameObj, "door", range(4), 0, 0, 41, 25, 82, 50, False)
    gameObj.anim["exit"] = anim_c(gameObj.img["doorAnimExit"], gameObj, "exit", range(1), 0, 0, 34, 82, 50, 64)

    #remember to delete the anims from this list as you add them above
    """
    gameObj.anim["miner_right"] = anim_c(gameObj.img["allDudes"], gameObj, "miner_right", range(24), 0, 4, 15, 31)
    gameObj.anim["miner_left"] = anim_c(gameObj.img["allDudes"], gameObj, "miner_left", range(23, -1, -1), 0, 5, 15, 31)

    gameObj.anim["dig_down"] = anim_c(gameObj.img["allDudes"], gameObj, "dig_down", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], 0, 10, 17, 26)
    gameObj.anim["float_start"] = anim_c(gameObj.img["allDudes"], gameObj, "float_start", [0,1,2,3,4,5], 0, 11, 15, 31)
    gameObj.anim["floater"] = anim_c(gameObj.img["allDudes"], gameObj, "floater", [0,1,2,3,4,5,6,7], 0, 12, 15, 31)
    gameObj.anim["chunk1"] = anim_c(gameObj.img["allDudes"], gameObj, "chunk1", [0,1,2,3,4,5,6,7,8,9,10,11,12], 0, 18, 15, 31)
    gameObj.anim["exitAnim"] = anim_c(gameObj.img["allDudes"], gameObj, "exitAnim", [0,1,2,3,4,5,6,7], 0, 19, 15, 31)

    #misc animations
    gameObj.anim["exit"] = anim_c(gameObj.img["exitSurface"], gameObj, "exit", range(6), 0, 0, 34, 64, 68, 64)
    gameObj.anim["entrance"] = anim_c(gameObj.img["doorAnimEntrance"], gameObj, "door", range(10), 0, 0, 41, 25, 82, 50, False)

    #grab a couple sounds
    gameObj.sound["letsgo"] = pygame.mixer.Sound(os.path.join("data","sound","001_LETSGO.WAV"))
    """
    if gameObj.soundEnabled:
        gameObj.sound["pop"] = pygame.mixer.Sound(os.path.join("data","sound","popsplut.ogg"))
	
